/**
 * 功能描述 列表
 */
define(function (require, exports, module) {
	var Grid = require("grid"); 	
	var aw = require("ajaxwrapper")
	
	var register = require("../store/register");
	
    var instance = {
        initComponent: function (params, widget) {
        	var grid = new Grid({
                parentNode : ".J-grid-register",
                url : "api/mail/queryall",
                autoRender:false,
                params : function(){
                	return {
                		"plan.pkPlan":widget.get("pkPlan"),
                		"productRule.product.pkProduct":widget.get("subnav").getValue("product"),
                		flag:widget.get("subnav").getValue("status"),
                		fetchProperties : register.fetchProperties
                	}
                },
                model : {
                    columns : [{
                        name : "member.personalInfo.name",
                        label : "姓名"                        
                    },{
                        name : "member.personalInfo.sex.value",
                        label : "性别"
                    },{
                        name : "member.personalInfo.idNumber",
                        label : "身份证号"
                    },{
                        name : "member.personalInfo.mobilePhone",
                        label : "手机号"
                    },{                    	
                        name : "member.personalInfo.contactAddresses",
                        label : "家庭地址" ,
                        format:function(value,row){
							var address = row.member.personalInfo.contactAddresses;
							if(address.length==0){
								return "";
							}
				    		for(var i=0;i<address.length;i++){
								if(!address[i].deleteFlag && address[i].addressStatus.key == "DefaultAddress"){
									if(address[i].communityData!=null){
										return address[i].address.fullName+"  "+address[i].communityData.name+"小区"+address[i].buildingNumber+"号楼"
						    			  +address[i].unitNumber+"单元"+address[i].doorNumber+"室";
									}else if(address[i].detailAddress!=null){
										return address[i].detailAddress;
									}else{
										return "";
									}
								}
							}
						}
                    },{
                        name : "mailMethod.value",
                        label : "邮寄方式"
                    },{
                        name : "status",                       
                        label : "已邮寄"
                    },{
                        name : "commonUser.name",
                        label : "经办人"
                    },{
                        name : "mailTime",
                        label : "邮寄日期",
                        format : "date"
                    }]
                }
            });
        	widget.set("grid",grid);
        }
    };
    module.exports = instance;
});
